package com.kailu.hotel.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.kailu.hotel.service.CustomerManager;
import com.kailu.hotel.service.HistoryManager;

/**
 * @author viet.ch
 * @generated May 16, 2014
 * @from VN
 */

@Controller
public class HistoryController {

	@Autowired
	HistoryManager historyManager;
	@Autowired
	CustomerManager customerManager;
	
	@RequestMapping("/history")
	public String initHistory(ModelMap map) {
		map.addAttribute("historyList", historyManager.getAllHistory());
		map.addAttribute("customerList", customerManager.getAllCustomer());
		return "history";
	}
	
	@RequestMapping(value ="/history", method = RequestMethod.POST)
	public String search(@ModelAttribute("in_date") String in_date, @ModelAttribute("out_date") String out_date, ModelMap map){
		map.addAttribute("historyList", historyManager.search(in_date, out_date));
		return "history";
	}
}
